// 切换视频和图片
$(".gamedbitem3 .videoimgbox .item_ li").click(function(){
    $(this).addClass("on").siblings().removeClass("on");
    if($(this).parents(".item_").hasClass("imgbox")){
        var src=$(this).find("img").attr("src")
        $(".gamedbitem3 .video-img img").show()
        $(".gamedbitem3 .video-img img").attr("src",src)
        $(".gamedbitem3 .video-img iframe").addClass("hide")
    }else{
        var src=$(this).attr("data-url")
        $(".gamedbitem3 .video-img img").hide()
        $(".gamedbitem3 .video-img iframe").removeClass("hide")
        $(".gamedbitem3 .video-img iframe").attr("src",src)
    }
})
// 显示已购
function openPurchased() {
    layer.closeAll();
    var layer_ = layer.open({
        type: 1,
        skin: 'darkthem',
        title: false,
        closeBtn: 1,
        shadeClose: false,
        content: $('.layerPurchased')
    });
}
// 切换显示详情
$(".gamedbitem2 ul li").click(function(){
   var name=$(this).attr("data-name") 
   var img=$(this).attr("data-img")
   var score=$(this).attr("data-score")
   var time=$(this).attr("data-time")
   var text=$(this).attr("data-text")
   var url=$(this).attr("data-url")
   $(".layernamescore .name").text(name)
   $(".layernamescore .time").text(time)
   $(".layernamescore .score-tex").text(score)
   $(".layernamescore .text").text(text)
   $(".layernamescore .img").attr('src',img)
   $(".layernamescore .more").attr('href',url)
   var layer_ = layer.open({
        type: 1,
        skin: 'darkthem',
        title: false,
        closeBtn: 1,
        shadeClose: false,
        content: $('.layernamescore')
    });
})
// 显示发表评价
function openlayerevaluateAuthor() {
    layer.closeAll();
    var layer_ = layer.open({
        type: 1,
        skin: 'darkthem',
        title: false,
        closeBtn: 1,
        shadeClose: false,
        content: $('.layerevaluate-author')
    });
}
// 显示添加标签
function openlayerlabel(obj) {
    var lablis=$(obj).parents('.tablis').html().replace(/<span[^>]*>(.|\n)*<\/span>/gi,"");
    $(".layerlabel .default").html(lablis)
    layer.closeAll();
    var layer_ = layer.open({
        type: 1,
        skin: 'darkthem',
        title: false,
        closeBtn: 1,
        shadeClose: false,
        content: $('.layerlabel')
    });
    var Checkarr=[];  //提交可以提交这个数组是选中的
    $(".layerlabel .Check .tab").each(function(){
        var i=$(this).find("span").text();
        Checkarr.push(i)
    })
    $(".layerlabel .default .tab").click(function(){
        var name=$(this).text()
        add(name)
    })
    function add(name){
        if(Checkarr.indexOf(name)>-1){
            layer.msg('不能显示重复标签'); 
            return false;
        }else{
            $(".layerlabel .Check").append('<div class="tab"><span>'+name+'</span><i>x</i></div>')
            Checkarr.push(name)
        }
    }
    $(".layerlabel .Check ").on('click','.tab i',function(){
        var i=$(this).parents(".tab").index();
        Checkarr.splice(i,1)
        $(this).parents('.tab').remove()
    }) 
    $(".layerlabel .inputbox span").click(function(){
        var name=$(this).parents(".inputbox").find("input").val()
        if(name==''){
            layer.msg('请填写标签'); 
            return false;
        }else{
            add(name)
        }
    })
}
// 属性hover提示
var layergamedbdatahover
$(".gamedbdatahover").on({
    mouseenter: function () {
        var text = $(this).attr("data-text");
        var content = '';
        content += '<div class="commt">'
        content += '<div class="icogame"></div>'
        content += '<div class="text">' + (text ? text : '') + '</div>'
        content += '</div>'
        layergamedbdatahover=layer.tips(content, this, { tips: [2, '#666666'], time: 0, skin: 'layertipsgamedb' });
    },
    mouseleave: function () {
        layer.close(layergamedbdatahover)
    }
})
// 显示贡献
function openlayercontribution() {
    layer.closeAll();
    var layer_ = layer.open({
        type: 1,
        skin: 'darkthem',
        title: false,
        closeBtn: 1,
        shadeClose: false,
        content: $('.layercontribution')
    });
}
// 贡献弹出层分类
$(".layercontribution .tabbox li").click(function(){
    var type=$(this).attr("data-type");
    $('.layercontriwarp').find('.'+type+'').show().siblings().hide();
    var layer_ = layer.open({
        type: 1,
        skin: 'darkthem',
        title: false,
        closeBtn: 1,
        shadeClose: false,
        content: $('.layercontriwarp')
    });
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
        ,layer = layui.layer
        form.on('submit(contribution)', function(data){
            data.field['datatype'] = type;
            // datatype 是分类的类型''
            // 这里提交数据 下面的弹出层上线后可以去掉
            layer.alert(JSON.stringify(data.field), {
              skin: 'darkthem',
            })
            return false;
          });  
    })
})
// 自定义提示框
function layeralter(text) {
    $('.layeralter .commt .text').text(text)
    var layer_ = layer.open({
        type: 1,
        time:3000,
        skin: 'layeralterthem',
        title: false,
        closeBtn: 0,
        shade:false,
        shadeClose: true,
        content: $('.layeralter')
    });
}
// 显示推荐
function openrecommend(obj){
    var number=Number($(obj).find(".recommend").text());
    if($(obj).hasClass("on")){
        layeralter('您推荐过了')
        return false
    }else{
        $(obj).find(".recommend").text(number+1);
        $(obj).addClass("on")
    }
    layeralter('感谢您的推荐，这会让贡献者能量爆棚')
}
// 列表点击阻止
function layergamedblist(obj) {
    var img=$(obj).find('img').attr('src')
    var href=$(obj).find('.tex').attr('href')
    var title=$(obj).find('.tex').text()
    var name=$(obj).attr("data-name")
    var recommend=$(obj).attr("data-recommend")
    var browse=$(obj).attr("data-browse")
    var web=$(obj).attr("data-web")
    $('.layergamedblist').find(".lab").removeClass("on")
    $('.layergamedblist').find(".imgbox img").attr('src',img)
    $('.layergamedblist').find(".lab.link").attr('href',href)
    $('.layergamedblist').find(".imgbox .name").text(name)
    $('.layergamedblist').find(".title").text(title)
    $('.layergamedblist').find(".recommend").text(recommend)
    $('.layergamedblist').find(".browse").text(browse)
    $('.layergamedblist').find(".web").text(web)
    layer.closeAll();
    var layer_ = layer.open({
        type: 1,
        skin: 'darkthem',
        title: false,
        closeBtn: 1,
        shadeClose: true,
        content: $('.layergamedblist')
    });
}